import { View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import classNames from 'classnames';
import React from 'react';
import { noop } from '../../../utils/fn';
import CustomNavBar from '../CustomNavBar';
import styles from './index.module.scss';

const DefaultNavBar = ({
  back = true,
  menuBlock = true,
  title = '',
  onClick = noop,
  onTitleClick = onClick,
  className = '',
  ...rest
}) => {
  const isAndroid = Taro.$platform === 'android';

  return (
    <CustomNavBar
      className={`${styles.DefaultNavBar} ${className} customNavigationBarStyle`}
      back={back}
      menuBlock={menuBlock}
      {...{
        onClick,
        ...rest,
      }}
    >
      <View onClick={onTitleClick} className={classNames('title omit', { android: isAndroid })}>
        {title}
      </View>
    </CustomNavBar>
  );
};

export default DefaultNavBar;
